//
//  VOH_SD_ImageaAndITitleVerticalButton.m
//  VoiceOfHeart
//
//  Created by lanou3g on 16/8/15.
//  Copyright © 2016年 吉龙. All rights reserved.
//

#import "VOH_SD_ImageaAndITitleVerticalButton.h"
static CGFloat kTextTopPadding = 10;


@implementation VOH_SD_ImageaAndITitleVerticalButton

-(void)layoutSubviews{
    [super layoutSubviews];
    //图片移动到顶部和其水平居中
    CGRect imageFram =self.imageView.frame;
    imageFram.origin.y = 0;
    imageFram.origin.x = (self.frame.size.width/2) - (imageFram.size.width/2);
    self.imageView.frame = imageFram;
    
    //调整大小适合的标签文本,并向下移动图像
    CGRect titleLabelFrame = self.titleLabel.frame;
    CGSize labelSize = [self.titleLabel.text sizeWithFont:self.titleLabel.font
                                        constrainedToSize:CGSizeMake(self.frame.size.width, CGFLOAT_MAX)
                                            lineBreakMode:NSLineBreakByWordWrapping];
    titleLabelFrame.size.width = labelSize.width;
    titleLabelFrame.size.height = labelSize.height;
    titleLabelFrame.origin.x = (self.frame.size.width / 2) - (labelSize.width / 2);
    titleLabelFrame.origin.y = self.imageView.frame.origin.y + self.imageView.frame.size.height + kTextTopPadding;
    self.titleLabel.frame = titleLabelFrame;
}


@end
